<?php
    require_once('maincore.php');
	require_once THEMES."templates/header.php";
	
	$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
mysql_select_db($GLOBALS['db_name'], $db);

 	
    $query = sprintf('select image_id, filename from images');
    $result = mysql_query($query, $db);
 
    $images = array();
 
    while ($row = mysql_fetch_array($result)) {
        $id = $row['image_id'];
        $images[$id] = $row['filename'];
    }

echo "
<html>
    <head>
        <title>Uploaded Images</title>
    </head>
    <body>
        <div>
            <h1>Uploaded Images</h1>
 
            <p>
                <a href='upload.php'>Upload an image</a>
            </p>
 
            <ul>";
                 if (count($images) == 0) { 
echo"         <li>No uploaded images found</li>";
                		 } else foreach ($images as $id => $filename) { 
echo"    	 <li>
                        <a href='view.php?id=$id'>";
echo"					htmlSpecialChars($filename)
                        </a>
                    </li>";
                 } 
echo"         </ul>
    </body>
</html>
";
	require_once THEMES."templates/footer.php";
?>